﻿using System;
using Sklad1_2.Data;
using Sklad1_2.Default;

namespace Sklad1_2.Search
{
    public partial class SearchClient : Defaultform
    {
        public SearchClient()
        {
            InitializeComponent();
            ABase.AddItemDBGridView(dataGridView1,Helper.QueryCustomer);
            Helper.Hidden(dataGridView1,0);
            textBox1.ReadOnly = true;
            textBox2.ReadOnly = true;
            textBox3.ReadOnly = true;
        }

        private string query;
            
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.ReadOnly = !checkBox1.Checked;
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            textBox2.ReadOnly = !checkBox2.Checked;
        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            textBox3.ReadOnly = !checkBox3.Checked;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            query = Helper.QueryCustomer;
            query += " and description like '%" + textBox1.Text + "%'";
            ABase.AddItemDBGridView(dataGridView1,query);
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            query = Helper.QueryCustomer;
            query += " and organization like '%" + textBox2.Text + "%'";
            ABase.AddItemDBGridView(dataGridView1, query);
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            query = Helper.QueryCustomer;
            query += " and address like '%" + textBox3.Text + "%'";
            ABase.AddItemDBGridView(dataGridView1, query);
        }
    }
}
